package extractLatAndLon;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

public class extractLatAndLon {

	public static void main(String[] args) {
		String inFilePath = "geoLatAndLonInput.ttl";
		String outFilePath = "geoLatAndLonOutput.ttl";
		File inFile = new File(inFilePath);
		File outputFile = new File(outFilePath);
		try {
			FileReader inReader = new FileReader(inFile.getAbsolutePath());
			FileWriter outWriter = new FileWriter(outputFile.getAbsolutePath(), true);
			BufferedReader bReader = new BufferedReader(inReader);
			BufferedWriter bWriter = new BufferedWriter(outWriter);
			String aLine = "", lat = "", lon = "";
			int start, end;
			while ((aLine = bReader.readLine()) != null) {
				start = aLine.indexOf("\"") + 1;
				end = aLine.lastIndexOf("\"");
				lat = aLine.substring(start, end);
				if ((aLine = bReader.readLine()) != null) {
					start = aLine.indexOf("\"") + 1;
					end = aLine.lastIndexOf("\"");
					lon = aLine.substring(start, end);

				}
				bWriter.write(lat + "\n" + lon + "\n");
				bWriter.flush();
			}
			bReader.close();
			bWriter.close();
			inReader.close();
			outWriter.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
